package com.yc.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yc.R_Code;
import com.yc.Result;
import com.yc.entities.BloodSugarArticleTry;
import com.yc.entities.custom.CustomArticleTryResponseBean;
import com.yc.mapper.BloodSugarArticleTryMapper;
import com.yc.service.BloodSugarArticleTryService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 试纸批号表 服务实现类
 * </p>
 *
 * @author kuakha
 * @since 2021-04-20
 */
@Service
public class BloodSugarArticleTryServiceImpl extends ServiceImpl<BloodSugarArticleTryMapper, BloodSugarArticleTry> implements BloodSugarArticleTryService {

    @Override
    public Result getArticleTryInfo(Integer deanId, Integer departmentId, String startTime, String endTime, Integer current, Integer size) {
        Page<Integer> page = new Page<>(current == null ? 0 : current, size == null ? 10 : size);
        List<CustomArticleTryResponseBean> allRoleInfo = this.baseMapper.getArticleTryInfo(page, deanId, departmentId,startTime, endTime);
        if (page.getTotal() >= 1) {
            return Result.ok().total((int) page.getTotal()).data(allRoleInfo);
        } else {
            return Result.ok().code(R_Code.R_NULL_DATA_FAIL);
        }
    }
}
